import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

/**
 * 位运算 位操作
 */
public class BitOperation {

    @Test
    public void bitOperationDemo() {
        int a = Integer.parseInt("2AAAAAAA", 16);
        System.out.println(Integer.toBinaryString(a));
        int b = Integer.parseInt("55555555", 16);
        System.out.println(Integer.toBinaryString(b));
        System.out.println(Integer.toBinaryString(a|b));

        Assertions.assertEquals(a|b,Integer.parseInt("7FFFFFFF", 16));
        Assertions.assertEquals(a&b,0);
        Assertions.assertEquals(a^b,Integer.parseInt("7FFFFFFF", 16));

        System.out.println(Integer.toBinaryString(~a));
    }
}
